package com.sias.reflection;

import java.io.File;
import java.lang.reflect.Constructor;
import java.lang.reflect.Method;

/**
 * @author 吴文杰
 * @version 1.0
 * @createTime 2023-05-02 17:48:54
 */
public class HomeWork02 {
  public static void main(String[] args) throws Exception {
    Class<?> cls = Class.forName("java.io.File");
    Constructor<?>[] constructors = cls.getDeclaredConstructors();
    for (Constructor<?> constructor : constructors) {
      System.out.println(constructor);
    }
    Constructor<?> constructor = cls.getConstructor(String.class);
    // File file = (File) constructor.newInstance("e:\\aa.txt");
    // file.createNewFile();
    Object o = constructor.newInstance("e:\\axa.txt");
    Method file = cls.getMethod("createNewFile");
    file.invoke(o);
  }
}

